Skip to content

Instantly share code, notes, and snippets.

struct ResetPasswordView: View {
enum ResponderFields: Int {
case password
case confirmPassword
}
@State private var firstResponder: ResponderFields? = nil
@State private var text: String = ""
var body: some View {
protocol NVTextFieldReturnKeyProtocol {
func returnTapped()
}
class NVTextFieldCoordinator: NSObject, UITextFieldDelegate, NVTextFieldReturnKeyProtocol {
@Binding private var text: String
private let onStartEditing: (() -> Void)
private let onEndEditing: (() -> Void)
private let onReturnTap: (() -> Void)
struct NVTextField<V: Hashable>: UIViewRepresentable {
@Binding var text: String
var id: V
@Binding var firstResponder: V?
private var onReturn: () -> Void
init(text: Binding<String>, id: V, firstResponder: Binding<V?>, onReturn: @escaping (() -> Void) = {}) {
self.id = id
_text = text
_firstResponder = firstResponder
fn parse<'de, T>(body: Bytes) -> Option<T>
where T: Deserialize<'de>
{
serde_json::from_reader(body.into_buf()).unwrap_or_default()
}
public static class Utils{
public static void Using<T>(T x, Action<T> func) where T: IDisposable
{
try {
func(x);
}catch(){
}finally{
x.Dispose();
}
.js-loading-overlay {
position:absolute;
top:0; bottom:0;
left:0; right:0;
z-index:199;
background:#fff;
opacity:0.5;
@graylikeme
graylikeme / .profile
Created August 7, 2012 12:20
.profile
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
RED='\[\033[0;31m\]'
YELLOW='\[\033[0;33m\]'
GREEN='\[\033[0;32m\]'
PS1="$RED\$(date +%H:%M) \w$YELLOW \$(parse_git_branch)$GREEN\$ "
2012-07-30T20:31:50+00:00 heroku[web.1]: Starting process with command `python dashword/dashword.py`
2012-07-30T20:31:51+00:00 app[web.1]: File "/app/dashword/handlers/UserHandler.py", line 1, in <module>
2012-07-30T20:31:51+00:00 app[web.1]: from models.Passwords import Password
2012-07-30T20:31:51+00:00 app[web.1]: File "dashword/dashword.py", line 5, in <module>
2012-07-30T20:31:51+00:00 app[web.1]: Traceback (most recent call last):
2012-07-30T20:31:51+00:00 app[web.1]: from handlers.UserHandler import LoginHandler, LogoutHandler, RegisterHandler, ProfileHandler, PasswordHandler, TeamHandler
2012-07-30T20:31:51+00:00 app[web.1]: ImportError: No module named Passwords
2012-07-30T20:31:52+00:00 heroku[web.1]: Process exited with status 1
2012-07-30T20:31:53+00:00 heroku[web.1]: State changed from starting to crashed
@graylikeme
graylikeme / gist:3193683
Created July 28, 2012 14:59
osx highlighting
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
RED='\[\033[0;31m\]'
YELLOW='\[\033[0;33m\]'
GREEN='\[\033[0;32m\]'
PS1="$RED\$(date +%H:%M) \w$YELLOW \$(parse_git_branch)$GREEN\$ "
13:53 ~ $ pip
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here