Skip to content

Instantly share code, notes, and snippets.

View grigorye's full-sized avatar

Grigorii Entin grigorye

View GitHub Profile
@nepsilon
nepsilon / how-to-use-mac-keychain-to-store-github-repos-credentials.md
Created July 18, 2017 06:50
How to use Mac KeyChain to store GitHub repos credentials? — First published in fullweb.io issue #108

How to use Mac KeyChain to store GitHub repos credentials?

You know the pain, you cloned a repo over HTTPS, and now Git asks you for your password each time you want to push or pull.

Chances are you already have the git credential-osxkeychain command installed. If not, just install Git with brew: brew install git.

Once installed, just tell Git to use the KeyChain to store your credentials:

git config --global credential.helper osxkeychain
@ipbastola
ipbastola / jq to filter by value.md
Last active April 16, 2025 08:11
JQ to filter JSON by value

JQ to filter JSON by value

Syntax: cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'

Example: To get json record having _id equal 611

cat my.json | jq -c '.[] | select( ._id | contains(611))'

Remember: if JSON value has no double quotes (eg. for numeric) to do not supply in filter i.e. in contains(611)

extension Bool {
mutating func toggle() {
self = !self
}
}
var isExpanded: Bool = false
isExpanded.toggle()
@gbaman
gbaman / HowToOTG.md
Last active May 9, 2025 20:48
Simple guide for setting up OTG modes on the Raspberry Pi Zero

Raspberry Pi Zero OTG Mode

Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulholland (gbaman).

The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.
It is also important to note, that a USB to UART serial adapter is not needed for any of these guides, as may be documented elsewhere across the int

xcrun llvm-cov report -use-color=true -instr-profile \
./Build/Intermediates/CodeCoverage/Coverage.profdata \
./Build/Intermediates/CodeCoverage/MyApp/Products/Debug-iphonesimulator/MyApp.app/MyApp
@beccadax
beccadax / Example.swift
Last active March 6, 2020 16:10
Elegant handling of localizable strings in Swift. Note: This code is in Swift 2 and would need updates to be used in modern Swift.
let color = "blue"
let num = 42
localized("Colorless green ideas sleep furiously.")
localized("Colorless \(color) ideas sleep furiously.")
localized("\(num.formatted("%05d")) colorless green ideas sleep furiously.")
extension String {
func replacePrefix(prefix: String, replacement: String) -> String {
if hasPrefix(prefix) {
return replacement + substringFromIndex(prefix.endIndex)
}
else {
return self
}
}
}
@drewreece
drewreece / AHT-my-disk.sh
Last active May 15, 2023 09:22
Install Apple Hardware Test to a volume and bless the AHT
#!/bin/sh
#
# AHT My Disk
#
# Copy Apple Hardware Test to a volume and bless the hardware test to be bootable
#
# Useful list of AHT & models from upekkha - https://github.com/upekkha/AppleHardwareTest thx u :)
# find your model details & get the AHT disk image
## sysctl hw.model | awk '{ print $2 }'
## ioreg -l | grep board-id | awk -F\" '{ print $4 }'
@lyoshenka
lyoshenka / pre-push.sh
Last active June 14, 2023 06:55 — forked from greglboxer/pre-push.sh
Git pre-push hook to prevent force-pushing or deleting a special branch (e.g. master)
#!/bin/bash
# Requires git 1.8.2 or newer
# Prevents force-pushing or deleting a special branch (e.g. master).
# Based on: https://gist.github.com/pixelhandler/5718585 and https://gist.github.com/stefansundin/d465f1e331fc5c632088
# Install:
# cd path/to/git/repo
# curl -fL -o .git/hooks/pre-push https://gist.githubusercontent.com/lyoshenka/158cfff41d09e1dcf029/raw/pre-push.sh
# chmod +x .git/hooks/pre-push
@akosma
akosma / set.swift
Created September 3, 2014 13:20
Set operations described in Swift using operators and NSSet instances
// Set operations taken from
// https://en.wikipedia.org/wiki/Set_(mathematics)
import Foundation
// The empty set
let Ø = NSSet()
// The "Universal" set
let U = NSMutableSet()