Skip to content

Instantly share code, notes, and snippets.

View gatspy's full-sized avatar

CG.gatspy gatspy

View GitHub Profile
@fnky
fnky / ANSI.md
Last active April 25, 2025 07:48
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@niwatly
niwatly / GsonUtils.kt
Last active June 26, 2023 19:34
Gson Utils by Kotlin
//convert gson String to Map<K, V>. Crash when invalid structure found
inline fun <reified K, reified V> String.toMapByGson(): Map<K, V> = if (isNotEmpty()) {
Gson().fromJson<HashMap<K, V>>(this, TypeToken.getParameterized(HashMap::class.java, K::class.java, V::class.java).type)
} else {
mapOf<K, V>()
}
//convert gson String to List<T>. Crash when invalid structure found
inline fun <reified T> String.toListByGson(): List<T> = if (isNotEmpty()) {
Gson().fromJson<List<T>>(this, TypeToken.getParameterized(ArrayList::class.java, T::class.java).type)
@salmoni
salmoni / goQueryTest.go
Last active October 13, 2024 12:20
Parsing HTML in Go/Golang using goQuery to extract data from only one of multiple tables. Demonstrates nested Find statements.
package main
import (
"fmt"
"log"
"strings"
"github.com/PuerkitoBio/goquery"
)
@YumaInaura
YumaInaura / 00_README.md
Last active March 15, 2025 12:53
Golang — Understanding channel, buffer, blocking, deadlock and happy groutines.

Golang — Understanding channel, buffer, blocking, deadlock and happy groutines.

I was so confused to understand behaviior of Golang channels, buffer, blocking, deadlocking and groutines.

I read Go by Example topics.

@Godofbrowser
Godofbrowser / axios.refresh_token.1.js
Last active November 18, 2024 04:31 — forked from culttm/axios.refresh_token.js
Axios interceptor for refresh token when you have multiple parallel requests. Demo implementation: https://github.com/Godofbrowser/axios-refresh-multiple-request
// for multiple requests
let isRefreshing = false;
let failedQueue = [];
const processQueue = (error, token = null) => {
failedQueue.forEach(prom => {
if (error) {
prom.reject(error);
} else {
prom.resolve(token);
@LouisCAD
LouisCAD / LifecycleCoroutines.kt
Last active July 3, 2022 11:47
CoroutineScope and Job integration with Lifecycle for Android. Meant to be used for your coroutines in lifecycle aware components. OUTDATED. See up to date implementation here: https://github.com/LouisCAD/Splitties/tree/master/modules/lifecycle-coroutines
import android.arch.lifecycle.GenericLifecycleObserver
import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.Lifecycle.Event.ON_DESTROY
import android.arch.lifecycle.LifecycleOwner
import kotlinx.coroutines.experimental.CoroutineScope
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.android.Main
fun Lifecycle.createJob(cancelEvent: Lifecycle.Event = ON_DESTROY): Job {
@piruin
piruin / AndroidThread.kt
Created October 30, 2017 09:41
Kotlin's Extension for Easy Handler Thread
package org.tanrabad.survey.larvaecam
import android.app.Fragment
import android.content.Context
import android.os.AsyncTask
import android.os.Handler
import android.os.Looper
import android.view.View
inline fun Context.runOnWorkerThread(crossinline task: () -> Unit) {
@tombigel
tombigel / README.md
Last active March 18, 2025 18:49 — forked from a2ikm/limit.maxfiles.plist
How to Change Open Files Limit on OS X and macOS Sierra (10.8 - 10.12)

How to Change Open Files Limit on OS X and macOS

This text is the section about OS X Yosemite (which also works for macOS Sierra) from https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/#mac-os-x

The last time i visited this link it was dead (403), so I cloned it here from the latest snapshot in Archive.org's Wayback Machine https://web.archive.org/web/20170523131633/https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/

Mac OS X

To check the current limits on your Mac OS X system, run:

@linw1995
linw1995 / WaterMark.go
Last active February 8, 2023 06:48
Using golang to mark the picture
package main
import (
"bytes"
"fmt"
"strings"
"io/ioutil"
"os"
"path"
@harshavardhana
harshavardhana / nginx-minio-static.md
Last active April 19, 2025 23:56 — forked from koolhead17/gist:4b8dd8d95ec86368634693cf9ad9391c
How to configure static website using Nginx with MinIO ?

How to configure static website using Nginx with MinIO ?

1. Install nginx

2. Install minio

3. Install mc client

4. Create a bucket:

$ mc mb myminio/static
Bucket created successfully ‘myminio/static’.