Skip to content

Instantly share code, notes, and snippets.

View pai911's full-sized avatar

John Bai pai911

View GitHub Profile
@pai911
pai911 / Twitter.json
Created March 13, 2024 10:41
Twitter.json
{
"data": [
{
"id": "834633353273827328",
"referenced_tweets": [
{
"type": "retweeted",
"id": "834402292539416576"
}
],
@pai911
pai911 / Method 1: Brute Force.java
Last active January 22, 2021 05:14
30. Substring with Concatenation of All Words
class Solution {
public List<Integer> findSubstring(String str, String[] words) {
Map<String, Integer> wordFrequencyMap = new HashMap<>();
for (String word : words)
wordFrequencyMap.put(word, wordFrequencyMap.getOrDefault(word, 0) + 1);
List<Integer> res = new ArrayList<Integer>();
int wordsCount = words.length;
int wordLength = words[0].length();
@pai911
pai911 / _helpers.tpl
Created April 28, 2020 03:30
Add Init Script to Solr Helm chart
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "solr.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
@pai911
pai911 / Extension.swift
Created July 17, 2019 03:35
An extension to help center image and title in UIButton. The position of the image and title can be reversed.
extension UIButton {
func alignHorizontal(spacing: CGFloat, imageFirst: Bool) {
let edgeOffset = spacing / 2
imageEdgeInsets = UIEdgeInsets(top: 0,
left: -edgeOffset,
bottom: 0,
right: edgeOffset)
titleEdgeInsets = UIEdgeInsets(top: 0,
left: edgeOffset,
@pai911
pai911 / mail_util.py
Last active July 17, 2019 03:36
A util to read an email file
import email
from email.header import decode_header
# http://imsardine.simplbug.com/note/email/python.html
class Email(object):
def __init__(self, rfc822):
self._rfc822 = rfc822
self._message = email.message_from_string(rfc822)
@pai911
pai911 / LoadingSpinnerOverlay.swift
Created January 25, 2016 05:14
Create a simple spinner without using any library
import Foundation
public class LoadingSpinnerOverlay{
var overlayView = UIView()
var activityIndicator = UIActivityIndicatorView()
class var shared: LoadingSpinnerOverlay {
@pai911
pai911 / UINavigationBarTaller.swift
Last active August 27, 2016 19:16
Custom Navigation Bar with increased height (tested on iOS 8.0)
//
// UINavigationBarTaller.swift
//
import UIKit
class UINavigationBarTaller: UINavigationBar {
///The height you want your navigation bar to be of
static let navigationBarHeight: CGFloat = 64