Skip to content

Instantly share code, notes, and snippets.

extension ViewController: UITextDragDelegate {
func textDraggableView(_ textDraggableView: UIView & UITextDraggable, dragPreviewForLiftingItem item: UIDragItem, session: UIDragSession) -> UITargetedDragPreview? {
let dragView = textDraggableView
let selectionRange = textDraggableView.selectedTextRange
let selectionRects = textDraggableView.selectionRects(for: selectionRange!) as! [UITextSelectionRect]
var array: [CGRect] = []
@averagesecurityguy
averagesecurityguy / pdf_flatedecode.py
Last active June 10, 2024 00:19
Decompress FlateDecode Objects in PDF
#!/usr/bin/env python3
# This script is designed to do one thing and one thing only. It will find each
# of the FlateDecode streams in a PDF document using a regular expression,
# unzip them, and print out the unzipped data. You can do the same in any
# programming language you choose.
#
# This is NOT a generic PDF decoder, if you need a generic PDF decoder, please
# take a look at pdf-parser by Didier Stevens, which is included in Kali linux.
# https://tools.kali.org/forensics/pdf-parser.
#
@hotwatermorning
hotwatermorning / level_meter_impl.md
Last active November 26, 2023 00:18
DAWごとのレベルメーターの実装比較

Bitwig Studio

レベルメーターの特徴

  • ピーク値とRMS値が表示できる。
  • ピークホールド時間の設定や、RMS値を集計する区間の長さの設定、メーター値の減少速度を設定する仕組みはない。
  • 2種類の表示モードがあるが、どちらも信号のピーク値とRMS値(二乗平均平方根。区間の平均エネルギーを表す。ピーク値と異なり、実際の音量感に近い値になる。)の両方が表示される。
  • トラックのボリュームコントロールのところに表示されている通常のレベルメーターの他に、大きく見やすいBit Meterと呼ばれるレベルメーターが用意されている。  - 表示される内容はどちらも同じ
@nownabe
nownabe / .commit_template
Created July 5, 2016 06:54
Emojiで楽しく綺麗なコミットを手に入れる
# ==== Emojis ====
# 🐛 :bug: バグ修正
# 👍 :+1: 機能改善
# ✨ :sparkles: 部分的な機能追加
# 🎉 :tada: 盛大に祝うべき大きな機能追加
# ♻️ :recycle: リファクタリング
# 🚿 :shower: 不要な機能・使われなくなった機能の削除
# 💚 :green_heart: テストやCIの修正・改善
@KentarouKanno
KentarouKanno / UITextField.md
Last active April 19, 2021 02:48
UITextField

UITextField

★ UITextFieldの生成

var textField = UITextField()

var textField: UITextField = UITextField()

// 位置、サイズを指定して生成
cmd := exec.Command("/bin/sh", "-c", "watch date > date.txt")
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
start := time.Now()
time.AfterFunc(3*time.Second, func() {
syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
})
err := cmd.Run()
fmt.Printf("pid=%d duration=%s err=%s\n", cmd.Process.Pid, time.Since(start), err)
@shgeta
shgeta / sandbox-exec_bash.md
Last active August 18, 2016 04:25
軽い防御付きbashの起動(osx)

# 軽い防御付きbashの起動(osx sandbox) ### 概要 ちょっとしたもらいもののスクリプトを動かす時、大変なことになっちゃわないか確認したい。コピペミスっててもやばいことにならないでほしい。って時に使うbash。 また、自分製のスクリプトを他の人のパソコンで動かしてもらう時に、相手の不安感を和らげるためにも使えるでしょう。

基本何でも許可、ネットワーク禁止、ファイル書き込み禁止(除外:/dev/tty /tmp/ /var/folders/ ) ファイルアクセス禁止(/id_rsaで終わるもの。.pemで終わるもの)

気になるものはどんどんdenyしていきましょう!

  • 🎨 when improving the format/structure of the code
  • 🚀 when improving performance
  • ✏️ when writing docs
  • 💡 new idea
  • 🚧 work in progress
  • ➕ when adding feature
  • ➖ when removing feature
  • 🔈 when adding logging
  • 🔇 when reducing logging
  • 🐛 when fixing a bug
@icyleaf
icyleaf / ar_migrate.rb
Last active June 6, 2024 20:06
ActiveRecord type of integer (tinyint, smallint, mediumint, int, bigint)
# activerecord-3.0.0/lib/active_record/connection_adapters/mysql_adapter.rb
# Maps logical Rails types to MySQL-specific data types.
def type_to_sql(type, limit = nil, precision = nil, scale = nil)
return super unless type.to_s == 'integer'
case limit
when 1; 'tinyint'
when 2; 'smallint'
when 3; 'mediumint'
when nil, 4, 11; 'int(11)' # compatibility with MySQL default
@L422Y
L422Y / osx_automount_nfs.md
Last active August 2, 2024 20:08
Automounting NFS share in OS X into /Volumes

I have spent quite a bit of time figuring out automounts of NFS shares in OS X...

Somewhere along the line, Apple decided allowing mounts directly into /Volumes should not be possible:

/etc/auto_master (see last line):

#
# Automounter master map
#

+auto_master # Use directory service