Skip to content

Instantly share code, notes, and snippets.

View stargt's full-sized avatar
🐔
Fried chicken

stargt stargt

🐔
Fried chicken
View GitHub Profile
import * as SecureStore from 'expo-secure-store';
import { chunk } from 'lodash';
const chunkString = (str: string, size: number) =>
chunk(str.split(''), size).map(s => s.join(''));
/**
* Secure Storage with support for storing strings larger than 2048 characters
*/
const ExpoSecureStoreAdapter = {
@kconner
kconner / macOS Internals.md
Last active April 22, 2024 21:28
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@pszemraj
pszemraj / inference_openai.py
Last active December 11, 2023 03:09
basic openai chat completion example
"""
inference_openai.py - text generation with OpenAI API
See https://platform.openai.com/docs/quickstart for more details.
Usage:
python inference_openai.py --prompt "The quick brown fox jumps over the lazy dog." --model "gpt-3.5-turbo" --temperature 0.5 --max_tokens 256 --n 1 --stop "."
Detailed usage:
python inference_openai.py --help
@kepano
kepano / obsidian-web-clipper.js
Last active May 3, 2024 07:21
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/turndown@6.0.0?module'), import('https://unpkg.com/@tehshrike/readability@0.2.0'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
@codelynx
codelynx / NSObject+class_copyPropertyList.swift
Last active March 21, 2024 08:22
Use class_copyPropertyList to extract properties from NSObject based object,
// source:
// https://stackoverflow.com/questions/24750186/i-cant-get-properties-of-a-class-using-swift-by-class-copypropertylist
import Foundation
extension NSObject {
func dictionaryRepresentation() -> [String: Any] {
@robertohein
robertohein / App.tsx
Last active January 15, 2024 22:00
React Native WebView persist state from localStorage on AsyncStorage and load state from AsyncStorage (useful with redux-persist)
import React, { useEffect, useRef, useState } from 'react';
import { StyleSheet } from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { SafeAreaView } from 'react-native-safe-area-context';
import WebView, { WebViewMessageEvent } from 'react-native-webview';
import { StatusBar } from 'expo-status-bar';
enum MessageTypes {
@wynch
wynch / Xcode_version_from_package.sh
Last active November 8, 2023 03:28
React Native - Set Gradle & XCode build version from package.json
#!/usr/bin/env bash -e
##
## Automatic version from package.json file
##
## Call this script from your XCode Scheme:
## - Copy / paste this script in a .sh file
## - Open your app scheme in XCode (shortcut: Cmd + <)
## - go to Build > Pre-actions
## - Add a run Script ('+' button in scheme window > "New Run Script Action"
@oldmud0
oldmud0 / gh-pages-old.md
Created May 1, 2018 22:16
Old GitHub Pages IP addresses for A records

On May 1, 2018, GitHub changed the suggested IP addresses to put on the A records for domains that use GitHub Pages. The new ones now support HTTPS for custom domains, but the old ones did not. Here are the old ones for historical purposes:

  • 192.30.252.153
  • 192.30.252.154

Here are the new ones:

  • 185.199.108.153
  • 185.199.109.153
  • 185.199.110.153

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).