This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Execute fc -p for the zsh shell if you want to remove it from the history. | |
# In this method, you don't pass the actual password value. | |
# Instead, you only send the first five characters of its SHA1 hash | |
# and then grep for the second part of the checksum locally within the response. | |
echo -n '<your_password>' | \ | |
openssl dgst -sha1 -hex | \ | |
awk '{print $2}' | \ | |
tr a-z A-Z | \ | |
xargs -I % sh -c 'curl -s "https://api.pwnedpasswords.com/range/$(echo % | cut -c -5)" | grep "$(echo % | cut -c 6-)"' | \ | |
cut -d ":" -f2 | \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example: vim (bzqfzf //...) | |
# Description: ZSH functions (should be easily converted to zsh) for Basel fuzzy search. | |
# Requirements: | |
# bazel | |
# brew install fzf | |
# brew install bat | |
# Add "source ~/.zsh_functions/bzqfzf.sh" to `~/.zshrc` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example: vim (bzqfzf //...) | |
# Description: Fish functions (should be easily converted to zsh) for Basel fuzzy search. | |
# Requirements: | |
# bazel | |
# brew install fzf | |
# brew install bat | |
# Note: Put each function to separate `.fish` file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
fr = "!f() { echo Fetch ${1:-$3} and rebase to ${1:-$3}/${2:-master} && git fetch ${1:-$3} && git rebase ${1:-$3}/${2:-master}; }; if git ls-remote --exit-code upstream > /dev/null; then f $1 $2 'upstream'; else f $1 $2 'origin'; fi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'json' | |
require 'io/console' | |
args = Hash[ ARGV.join(' ').scan(/--?([^=\s]+)(?:=(\S+))?/) ] | |
controller_url = args['controller'] | |
if controller_url.nil? | |
raise "You need to specify the controller: --controller=http://anka.controller.net" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol SomeProtocol { | |
func someMethod0() | |
func someMethod1() | |
func someMethod2() | |
func someMethod3() | |
func someMethod4() | |
func someMethod5() | |
func someMethod6() | |
func someMethod7() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Print all the commands in script before their execution | |
# export PS4='+ 6: ' | |
set -x | |
# Force the script to stop if any unhandled error occurs (i.e. an error not handled with `||`) | |
# set -e | |
# Force the script to stop if any uninitialized variable is used |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public extension Array { | |
public func asyncConcurrentEnumerated( | |
each: (_ object: Element, _ completion: @escaping () -> (), _ stop: () -> ()) throws -> ()) throws | |
{ | |
let dispatchGroup = DispatchGroup() | |
let array = NSArray(array: self) | |
var eachError: Error? | |
array.enumerateObjects(options: .concurrent) { obj, key, stop in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Dictionary { | |
func enumerateKeysAndObjects( | |
options opts: NSEnumerationOptions = [], | |
using block: (Any, Any, UnsafeMutablePointer<ObjCBool>) throws -> Void) throws | |
{ | |
var blockError: Error? | |
(self as NSDictionary).enumerateKeysAndObjects(options: opts) { (key, obj, stops) in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func toMainThread<T>(_ closure: @escaping (T) -> ()) -> ((T) -> ()) { | |
return { obj in | |
if Thread.isMainThread { | |
closure(obj) | |
} else { | |
DispatchQueue.main.async { | |
closure(obj) | |
} | |
} | |
} |
NewerOlder