Skip to content

Instantly share code, notes, and snippets.

View deepinder10's full-sized avatar

Deepinder Singh deepinder10

View GitHub Profile
@deepinder10
deepinder10 / redis-lz4-snappy-nodejs.js
Created April 28, 2024 03:42
Redis compression in NodeJS with LZ4 and Snappy
const Redis = require('ioredis');
const lz4 = require('lz4-napi');
const snappy = require('snappy');
async function compress() {
const compressedData = await lz4.compress(JSON.stringify(json));
// const compressedData = await snappy.compress(JSON.stringify(sampleData));
await client.set(key, compressedData);
}
@deepinder10
deepinder10 / rest_api_get_author_articles_hackerrank_js.js
Created February 2, 2023 10:08
REST API: Get Author Articles [Hackerrank] [Javascript] [Node.js]
async function fetchData(query) {
const URL = "https://jsonmock.hackerrank.com/api/articles?author="
return await axios.get(`${URL}${query}`);
}
function getTitles(articles) {
const result = [];
for (const article of articles) {
const titleKey = article.title || article.story_title;
if (titleKey) {
@deepinder10
deepinder10 / hosts_and_total_number_of_requests_hackerrank_js.js
Created February 2, 2023 10:06
Hosts and the Total Number of Requests [Hackerrank] [Javascript] [Node.js]
const readlinePkg = require('readline');
const fs = require('fs');
async function main() {
// read the string filename
const filename = readLine();
const rl = readlinePkg.createInterface({
input: fs.createReadStream(filename),
crfDelay: Infinity
})
@deepinder10
deepinder10 / emojis.json
Created March 31, 2020 19:49
emoji json twemoji
[
{
"name": "people",
"unicode": "1f642",
"char": "🙂",
"emojis": [
{
"name": "grinning face",
"unicode": "1f600",
"char": "😀"
.emoji-panel{
background-color: #fff;
box-shadow: 0 4px 4px 0 rgba(0,0,0,.06);
width: 400px;
}
.emoji-panel__heading{
background-color: #f0f0f0;
display: flex;
justify-content: space-between;
}
@deepinder10
deepinder10 / emoji-picker.jsx
Last active April 1, 2020 06:57
emoji-picker
import React, { useState } from 'react';
import './App.css';
import json from "./emojis.json";
function App() {
const [emojiIndex, setEmojiIndex] = useState(0);
/**
* Create the heading bar
*/
function createSvgHeading() {
private static final Pattern DIR_SEPORATOR = Pattern.compile("/");
/**
* Returns all available SD-Cards in the system (include emulated)
*
* Warning: Hack! Based on Android source code of version 4.3 (API 18)
* Because there is no standart way to get it.
* TODO: Test on future Android versions 4.4+
*
* @return paths to all available SD-Cards in the system (include emulated)
@deepinder10
deepinder10 / interactive-multi-level-dropdown.html
Created May 9, 2016 19:39
Multi Level Dependent DropDown HTML
<!doctype html>
<html>
<head>
<title></title>
<script language="javascript" src="list.js"></script>
</head>
<body>
<FORM name="drop_list" onsubmit=showAlert(); >
@deepinder10
deepinder10 / midsquare.py
Last active November 8, 2021 18:09
Mid Square Random Number Generator In Python
r=input("Enter number:\n")
l=len(str(r))
list = []
while len(list) == len(set(list)) :
x=str(r*r)
if l % 2 == 0:
x = x.zfill(l*2)
else:
x = x.zfill(l)
y=(len(x)-l)/2
@deepinder10
deepinder10 / marshmallowpermissions.java
Last active January 21, 2016 18:21
Marshmallow Permissions
private static final int give_write = 1;
// check whether permission is granted or not(in your on create method)
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
// show an explanation why permission is needed if it was denied before
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)) {