Skip to content

Instantly share code, notes, and snippets.

@nealsun
nealsun / HTLC.sol
Created August 31, 2020 07:37
Hashed Time-Locked Contract
// Hashed Time-Locked Contract transactions
// HashTimelocked contract for cross-chain atomic swaps
// @authors:
// Cody Burns <[email protected]>
// license: Apache 2.0
/* usage:
Victor (the "buyer") and Peggy (the "seller") exchange public keys and mutually agree upon a timeout threshold.
Peggy provides a hash digest. Both parties can now
- construct the script and P2SH address for the HTLC.
@nealsun
nealsun / qr.swift
Last active March 1, 2019 02:55
generate qr image
import CoreImage
func generateCode(_ string: String, foregroundColor: UIColor = .black, backgroundColor: UIColor = .white) {
guard let filter = filter,
let data = string.data(using: .isoLatin1, allowLossyConversion: false) else {
return
}
filter.setValue(data, forKey: "inputMessage")
@nealsun
nealsun / pre-commit
Last active August 18, 2017 07:27 — forked from candostdagdeviren/pre-commit
Git Pre-Commit hook with SwiftLInt
#!/bin/bash
#Path to swiftlint
SWIFT_LINT=/usr/local/bin/swiftlint
#if $SWIFT_LINT >/dev/null 2>&1; then
if [[ -e "${SWIFT_LINT}" ]]; then
count=0
for file_path in $(git ls-files -m --exclude-from=.gitignore | grep ".swift$"); do
export SCRIPT_INPUT_FILE_$count=$file_path

###Note Apple will reject apps that are using private url schemes (Ugh, Apple....) if they are pretty much obvius. Some apps are rejected and others are not, so, be aware of this issue before implementing any of those URL's in your app as a feature.

[UPDATE : Not yet tested in iOS 10. It will fail because of policies changes in URL scheme handling.]

[UPDATE 2:The openURL() method of UIApplication is now deprecated. You should use application(_:open:options:) instead]

##[UPDATE 3: For now you just can use url schemes to open your apps's settings with Swift 3.0 (Xcode 8). I'll keep you informed when OS preferences can be reached]

@nealsun
nealsun / build_rtmp.sh
Last active October 13, 2016 02:58
build librtmp
#!/bin/sh
SDKVERSION="10.0" #ios sdk version
CURRENTPATH=`pwd`
ARCHS="i386 x86_64 armv7 armv7s arm64"
LIBPATH="${CURRENTPATH}/lib" #openssl的库放在这里
INCLUDEPATH="${CURRENTPATH}/include" #openssl的headers
LIBRTMPREPO="git://git.ffmpeg.org/rtmpdump"
@nealsun
nealsun / build_openssl.sh
Created October 13, 2016 02:51
build openssl for ios
#!/bin/bash
# Yay shell scripting! This script builds a static version of
# OpenSSL ${OPENSSL_VERSION} for iOS 7.0 that contains code for
# armv6, armv7, arm7s and i386.
set -x
# Setup paths to stuff we need
@nealsun
nealsun / # node - 2016-09-23_16-59-36.txt
Created September 23, 2016 09:16
node on macOS 10.12.1 - Homebrew build logs
Homebrew build logs for node on macOS 10.12.1
Build date: 2016-09-23 16:59:36
@nealsun
nealsun / xcode-build-bump.sh
Created May 14, 2016 08:27 — forked from sekati/xcode-build-bump.sh
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
@nealsun
nealsun / srgb2calibratedRGB
Created February 9, 2015 08:22
replace srgb to calibratedRGB
find . \( -name "*.xib" -or -name "*.storyboard" \) -print0 | xargs -0 sed -i '' -e 's/colorSpace="custom" customColorSpace="sRGB"/colorSpace="calibratedRGB"/g'