Skip to content

Instantly share code, notes, and snippets.

View silentsudo's full-sized avatar

Ashish Agre silentsudo

  • Bangalore
View GitHub Profile
@patrickfav
patrickfav / AesGcmTest.java
Last active February 27, 2024 11:32
Java Authenticated Encryption with AES and GCM.
package at.favre.lib.bytes.otherPackage;
import org.junit.Test;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
@charliememory
charliememory / gist:34bc5a9a89c8eb849baae27edc90731e
Last active June 1, 2020 03:56
tensorflow implement of bounding box to mask transform
## ref: https://stackoverflow.com/questions/34128104/tensorflow-creating-mask-of-varied-lengths
def tf_bbox2mask(y1, x1, y2, x2, img_H, img_W):
## Repeat for each row or column
y1_transposed = tf.expand_dims(tf.tile(y1,[img_W]), 0)
x1_transposed = tf.expand_dims(tf.tile(x1,[img_H]), 1)
y2_transposed = tf.expand_dims(tf.tile(y2,[img_W]), 0)
x2_transposed = tf.expand_dims(tf.tile(x2,[img_H]), 1)
## Get the range grid
range_row = tf.cast(tf.expand_dims(tf.range(0, img_H, 1), 1), tf.int32)
range_col = tf.cast(tf.expand_dims(tf.range(0, img_W, 1), 0), tf.int32)
@tribals
tribals / Pipfile
Last active January 11, 2024 16:22
Understanding SQL row locking - `SELECT FOR UPDATE`
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
SQLAlchemy = "*"
"psycopg2-binary" = "*"
[dev-packages]
@Jonalogy
Jonalogy / handling_multiple_github_accounts.md
Last active April 29, 2024 13:49
Handling Multiple Github Accounts on MacOS

Handling Multiple Github Accounts on MacOS

The only way I've succeeded so far is to employ SSH.

Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config file in a .ssh directory. The config file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh directory by default. You can navigate to it by running cd ~/.ssh within your terminal, open the config file with any editor, and it should look something like this:

Host *
 AddKeysToAgent yes

> UseKeyChain yes

@michalkejzlar
michalkejzlar / DownloadProductPicturesUseCase.java
Created February 12, 2017 19:36
Android - Download multiple pictures from remote server at once and save them into local path using Picasso, Okio and RxJava
import android.content.Context;
import android.net.Uri;
import android.util.Log;
import com.fernandocejas.frodo.annotation.RxLogObservable;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import okio.BufferedSink;
import okio.BufferedSource;
import okio.Okio;
anonymous
anonymous / esclient.go
Created January 12, 2017 15:27
Elastic Search client
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"strconv"
)
@mbunyard
mbunyard / MockResponseInterceptor.java
Created November 18, 2016 21:11
OkHttp3 interceptor which provides a mock response from local resource file.
package com.rogerthat.network.util;
import android.content.Context;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLConnection;
import okhttp3.Interceptor;
@michael-simons
michael-simons / ThingEntity.java
Last active October 19, 2020 16:15
An example on how to use Hibernate-Spatial with Spring Data JPA Repositories
@Entity
@Table(name = "things")
public class ThingEntity {
@Id
private Long id;
// Needed for use with Hibernate Spatial 4.x
// @Type(type = "org.hibernate.spatial.GeometryType")
private Geometry geometry;
@bennylope
bennylope / ffmpeg-watermark.md
Created April 22, 2016 23:17 — forked from webkader/ffmpeg-watermark.md
FFmpeg add a watermark to video

How to Add a Watermark to Video

FFMPEG filters provide a powerful way to programmatically enhance or alter videos, and it’s fairly simple to add a watermark to a video using the overlay filter. The easiest way to install ffmpeg is to download a pre-built binary for your specific platform. Then you don’t have to worry about including and installing all the right dependencies and codecs you will be using.

Once you have ffmpeg installed, adding a watermark is as easy as passing your existing source through an overlay filter like so:

ffmpeg -i test.mp4 -i watermark.png -filter_complex "overlay=10:10" test1.mp4

Basically, we’re passing in the original video, and an overlay image as inputs, then passing it through the filter, and saving the output as test1.mp4.