Skip to content

Instantly share code, notes, and snippets.

View abhishekhugetech's full-sized avatar
🎯
Focusing

Abhishek Kumar Singh abhishekhugetech

🎯
Focusing
View GitHub Profile
@solenoid
solenoid / gist:1372386
Created November 17, 2011 04:49
javascript ObjectId generator
var mongoObjectId = function () {
var timestamp = (new Date().getTime() / 1000 | 0).toString(16);
return timestamp + 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, function() {
return (Math.random() * 16 | 0).toString(16);
}).toLowerCase();
};
@danharper
danharper / background.js
Last active June 29, 2024 19:32
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@cachapa
cachapa / DownloadManager.java
Created November 21, 2015 15:11
General-purpose Android file downloads with threading and queuing. The only dependency is OkHttp.
package com.codingbuffalo.aerialdream.util;
import android.os.Handler;
import android.support.annotation.UiThread;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import java.io.File;
@suweya
suweya / FileUtil.java
Last active February 17, 2023 03:39
OkHttp download file by Okio
import android.os.Environment;
import android.support.annotation.NonNull;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.TimeUnit;
@hSATAC
hSATAC / install redis-cli.sh
Created June 7, 2022 05:15
Install redis-cli with tls in alpine
export REDIS_VERSION="6.0.4"
export REDIS_DOWNLOAD_URL="http://download.redis.io/releases/redis-${REDIS_VERSION}.tar.gz"
apk add --update --no-cache --virtual build-deps gcc make linux-headers musl-dev tar openssl-dev pkgconfig
wget -O redis.tar.gz "$REDIS_DOWNLOAD_URL"
mkdir -p /usr/src/redis
tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1
cd /usr/src/redis/src
make BUILD_TLS=yes MALLOC=libc redis-cli