Skip to content

Instantly share code, notes, and snippets.

View chibaye's full-sized avatar

chibaye chibaye

View GitHub Profile
@chibaye
chibaye / use-location.js
Created June 17, 2021 16:24 — forked from lenkan/use-location.js
React hook that keeps up to date with the current location.
// @ts-check
import { useState, useEffect } from 'react'
function getCurrentLocation () {
return {
pathname: window.location.pathname,
search: window.location.search
}
}
@chibaye
chibaye / SMSReceiver.java
Created June 17, 2021 11:32 — forked from chathudan/SMSReceiver.java
Android SMS Receive Listener
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import java.util.ArrayList;
/**
* @@author Chathura Wijesinghe <[email protected]>
@chibaye
chibaye / AutoResizeTextView.java
Created June 17, 2021 11:31 — forked from chathudan/AutoResizeTextView.java
Text view that auto adjusts text size to fit within the view. If the text size equals the minimum text size and still does not fit, append with an ellipsis.
import android.content.Context;
import android.text.Layout.Alignment;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.widget.TextView;
/**
* Text view that auto adjusts text size to fit within the view.
@chibaye
chibaye / youversion_abbreviations.js
Created June 8, 2021 05:45 — forked from danott/youversion_abbreviations.js
YouVersion.com URL Abbreviations
/*!
* youversion_abbreviations.js
* JSON of YouVersion.com Bible Book URL Abbreviations.
*/
var books = {
'gen': 'Genesis',
'exo': 'Exodus',
'lev': 'Leviticus',
'num': 'Numbers',
'deu': 'Deuteronomy',
{
"books-of-the-bible": {
"entry": [
{
"-handle": "01",
"name": {
"-handle": "genesis",
"#text": "Genesis"
},
"testament": {
@chibaye
chibaye / js
Created May 4, 2021 17:10
MongoDB multiple $lookup(s) and $match aggregation
// example data
db={
"cards": [
{
"_id": 1,
"number": "1353 5237 0976 6538",
"isActive": true,
"user": {
id: 2,
name: "Ben Kangwa"
package test;
import android.arch.lifecycle.LiveData;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
@chibaye
chibaye / lvh_ssl.md
Created April 3, 2021 11:37 — forked from dagjaneiro/lvh_ssl.md
lvh.me ssl

Install nginx

$ brew install nginx

Edit nginx.conf

$ vim /usr/local/etc/nginx/nginx.conf
@chibaye
chibaye / curl.md
Created March 2, 2021 18:32 — forked from btoone/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
db.users.aggregate([
{$group: {
_id: {$dateToString: {format: '%Y-%m', date: '$createdAt'}}
}},
{$lookup: {
from: 'users',
let: {startDate: {$subtract: [{$dateFromString: {dateString: '$_id'}}, 2592000000]}},
pipeline: [
{$match: {
$expr:{