When I open one emacs, everything works fine.
But when I open second emacs on different terminal,
error occurs
Debugger entered--Lisp error: (invalid-read-syntax "#")
signal(invalid-read-syntax ("#"))
(condition-case errvar (progn (load savehist-file nil (not (interactive-p))) (setq savehist-loaded t)) (error (setq savehist-mode nil) (savehist-uninstall) (signal (car errvar) (cdr errvar))))
(progn (condition-case errvar (progn (load savehist-file nil (not (interactive-p))) (setq savehist-loaded t)) (error (setq savehist-mode nil) (savehist-uninstall) (signal (car errvar) (cdr errvar)))))
(if (and (not savehist-loaded) (file-exists-p savehist-file)) (progn (condition-case errvar (progn (load savehist-file nil (not (interactive-p))) (setq savehist-loaded t)) (error (setq savehist-mode nil) (savehist-uninstall) (signal (car errvar) (cdr errvar))))))
(if (not savehist-mode) (savehist-uninstall) (if (and (not savehist-loaded) (file-exists-p savehist-file)) (progn (condition-case errvar (progn (load savehist-file nil (not (interactive-p))) (setq savehist-loaded t)) (error (setq savehist-mode nil) (savehist-uninstall)$
savehist-mode(1)
eval-buffer(#<buffer *load*> nil "/home/eugenekim/.emacs.d/init.el" nil t) ; Reading at buffer position 21294
load-with-code-conversion("/home/eugenekim/.emacs.d/init.el" "/home/eugenekim/.emacs.d/init.el" t t)
load("/home/eugenekim/.emacs.d/init" t t)
#[0 "^H\205\266^# \306=\203^Q^#\307^H\310Q\202?^# \311=\204^^^#\307^H\312Q\202?^#\313\307\314\315#\203*^#\316\202?^#\313\307\314\317#\203>^#\320\321\322!D\nB^R\323\202?^#\316\324^S\325^A\324\211#\210^K\324=\203e^#\326\327\330\307^H\331Q!\"\325^A\324\211#\210^K\324=\203$
command-line()
normal-top-level()
I tracked down it's # in ./emacs.d/history file, everything works fine if I delete lines with # in the file, but I'd like to fix it once and for all :(
It seems # in (setq minibuffer-history ..) is the problem.
(setq minibuffer-history '("/home/eugenekim/Documents/zibann/momsite/momsite/conf/dev/webpack.config.js" #("var" 0 3 (fontified t font-lock-face font-lock-keyword-face)) "review-meta-review" "review main thread view" "11" "webpack" "/home/eugenekim/Documents/zibann-" "in\
it" #("5-static-elements" 0 17 (dired-filename t mouse-face highlight help-echo "mouse-2: visit this file in other window" fontified t)) "/home/eugenekim/tmp/react-grid-layout/test/ex" "we" "/home/eugenekim/tmp/react-grid-layout/" "inhouse webpack" "webp" "/home/eugeneki\
m/tmp/react-grid-layout/" "packa" #("To" 0 2 (magit-section [cl-struct-magit-section process #<process git> #<marker (moves after insertion) at 18819 in *magit-process: zibann> #<marker at 18869 in *magit-process: zibann> #<marker at 19136 in *magit-process: zibann> nil \
nil nil nil nil #<process git> [cl-struct-magit-section processbuf nil #<marker (moves after insertion) at 19302 in *magit-process: zibann> nil #<marker at 19303 in *magit-process: zibann> nil nil nil nil nil nil nil ([cl-struct-magit-section process nil #<marker (moves \
after insertion) at 12596 in *magit-process: zibann> nil #<marker at 12615 in *magit-process: zibann> nil nil nil nil nil nil #6 nil] [cl-struct-magit-section process #<process git> #<marker (moves after insertion) at 12615 in *magit-process: zibann> #<marker at 12635 in\
*magit-process: zibann> #<marker at 12729 in *magit-process: zibann> t nil nil nil nil #<process git> #6 nil] [cl-struct-magit-section process #<process git> #<marker (moves after insertion) at 12729 in *magit-process: zibann> #<marker at 12781 in *magit-process: zibann\
> #<marker at 13055 in *magit-process: zibann> t nil nil nil nil #<process git> #6 nil] [cl-struct-magit-section process nil #<marker (moves after insertion) at 13055 in *magit-process: zibann> #<marker at 13094 in *magit-process: zibann> #<marker at 13179 in *magit-proc\
ess: zibann> t nil nil nil nil nil #6 nil] [cl-struct-magit-section process nil #<marker (moves after insertion) at 13179 in *magit-process: zibann> #<marker at 13219 in *magit-process: zibann> #<marker at 16090 in *magit-process: zibann> t nil nil nil nil nil #6 nil] [c\
l-struct-magit-section process nil #<marker (moves after insertion) at 16090 in *magit-process: zibann> nil #<marker at 16146 in *magit-process: zibann> nil nil nil nil nil nil #6 nil] [cl-struct-magit-section process nil #<marker (moves after insertion) at 16146 in *mag\
it-process: zibann> nil #<marker at 16973 in *magit-process: zibann> nil nil nil nil nil nil #6 nil] [cl-struct-magit-section process nil #<marker (moves after insertion) at 16973 in *magit-process: zibann> nil #<marker at 16992 in *magit-process: zibann> nil nil nil nil\
nil nil #6 nil] [cl-struct-magit-section process #<process git> #<marker (moves after insertion) at 16992 in *magit-process: zibann> #<marker at 17012 in *magit-process: zibann> #<marker at 18239 in *magit-process: zibann> t nil nil nil nil #<process git> #6 nil] [cl-st\
ruct-magit-section process nil #<marker (moves after insertion) at 18239 in *magit-process: zibann> nil #<marker at 18340 in *magit-process: zibann> nil nil nil nil nil nil #6 nil] [cl-struct-magit-section process #<process git> #<marker (moves after insertion) at 18340 \
in *magit-process: zibann> #<marker at 18360 in *magit-process: zibann> #<marker at 18449 in *magit-process: zibann> t nil nil nil nil #<process git> #6 nil] [cl-struct-magit-section process nil #<marker (moves after insertion) at 18449 in *magit-process: zibann> #<marke\
r at 18475 in *magit-process: zibann> #<marker at 18534 in *magit-process: zibann> t nil nil nil nil nil #6 nil] [cl-struct-magit-section process nil #<marker (moves after insertion) at 18534 in *magit-process: zibann> #<marker at 18568 in *magit-process: zibann> #<marke\
r at 18819 in *magit-process: zibann> t nil nil nil nil nil #6 nil] #5 [cl-struct-magit-section process nil #<marker (moves after insertion) at 19136 in *magit-process: zibann> #<marker at 19175 in *magit-process: zibann> #<marker at 19302 in *magit-process: zibann> nil \
nil nil nil nil nil #6 nil])] nil])) "/home/eugenekim/tmp/react-grid-layout/" "/home/eugenekim/tmp/react-grid-layout/package.json" "/home/eugenekim/tmp/grid" "/home/eugenekim/Documents/zibann/momsite/node_modules/react-g" "magit" "webpack" "magit:" "/home/eugenekim/Docum\
ents/zibann/momsite/apps/reservation/static/reservation/calendar/view_configs/calendar-day.react.js" "/home/eugenekim/Documents/zibann/momsite/apps/reservation/static/reservation/calendar/view_configs/month" "/home/eugenekim/Documents/zibann/momsite/apps/reservation/stat\
ic/reservation/calendar/view_configs/" "calendar view config react js" #("stash" 0 5 (face magit-hash magit-section [cl-struct-magit-section stash "stash#{8}" #<marker (moves after insertion) at 749 in *magit: zibann> nil #<marker at 1 in *magit: zibann> nil nil nil nil \
nil nil [cl-struct-magit-section stashes "refs/stash" #<marker (moves after insertion) at 749 in *magit: zibann> #<marker at 1 in *magit: zibann> #<marker at 1 in *magit: zibann> nil nil nil nil nil nil [cl-struct-magit-section status nil #<marker (moves after insertion)\
at 749 in *magit: zibann> nil #<marker at 1 in *magit: zibann> nil nil nil nil nil nil nil ([cl-struct-magit-section branch "feature/reservation" #<marker (moves after insertion) at 749 in *magit: zibann> #<marker at 1 in *magit: zibann> #<marker at 1 in *magit: zibann>\
nil nil nil nil nil nil #7 ([cl-struct-magit-section branch #("origin/feature/reservation" 0 26 (face magit-branch-remote)) #<marker (moves after insertion) at 749 in *magit: zibann> nil #<marker at 1 in *magit: zibann> nil nil nil nil nil nil #9 nil] [cl-struct-magit-s\
ection tag "saleor" #<marker (moves after insertion) at 749 in *magit: zibann> nil #<marker at 1 in *magit: zibann> nil nil nil nil nil nil #9 nil])] #6 [cl-struct-magit-section unpushed "#{upstream}.." #<marker (moves after insertion) at 749 in *magit: zibann> #<marker \
at 1 in *magit: zibann> #<marker at 1 in *magit: zibann> nil nil nil nil nil nil #7 ([cl-struct-magit-section commit "e7b4341" #<marker (moves after insertion) at 749 in *magit: zibann> nil #<marker at 1 in *magit: zibann> nil nil nil nil nil nil #9 nil])])] ([cl-struct-\
magit-section stash "stash#{0}" #<marker (moves after insertion) at 749 in *magit: zibann> nil #<marker at 1 in *magit: zibann> nil nil nil nil nil nil #6 nil] [cl-struct-magit-section stash "stash#{1}" #<marker (moves after insertion) at 749 in *magit: zibann> nil #<mar\
ker at 1 in *magit: zibann> nil nil nil nil nil nil #6 nil] [cl-struct-magit-section stash "stash#{2}" #<marker (moves after insertion) at 749 in *magit: zibann> nil #<marker at 1 in *magit: zibann> nil nil nil nil nil nil #6 nil] [cl-struct-magit-section stash "stash#{3\
}" #<marker (moves after insertion) at 749 in *magit: zibann> nil #<marker at 1 in *magit: zibann> nil nil nil nil nil nil #6 nil] [cl-struct-magit-section stash "stash#{4}" #<marker (moves after insertion) at 749 in *magit: zibann> nil #<marker at 1 in *magit: zibann> n\
il nil nil nil nil nil #6 nil] [cl-struct-magit-section stash "stash#{5}" #<marker (moves after insertion) at 749 in *magit: zibann> nil #<marker at 1 in *magit: zibann> nil nil nil nil nil nil #6 nil] [cl-struct-magit-section stash "stash#{6}" #<marker (moves after inse\
rtion) at 749 in *magit: zibann> nil #<marker at 1 in *magit: zibann> nil nil nil nil nil nil #6 nil] [cl-struct-magit-section stash "stash#{7}" #<marker (moves after insertion) at 749 in *magit: zibann> nil #<marker at 1 in *magit: zibann> nil nil nil nil nil nil #6 nil\
] #5 [cl-struct-magit-section stash "stash#{9}" #<marker (moves after insertion) at 749 in *magit: zibann> nil #<marker at 1 in *magit: zibann> nil nil nil nil nil nil #6 nil] [cl-struct-magit-section stash "stash#{10}" #<marker (moves after insertion) at 749 in *magit: \
zibann> nil #<marker at 1 in *magit: zibann> nil nil nil nil nil nil #6 nil] [cl-struct-magit-section stash "stash#{11}" #<marker (moves after insertion) at 749 in *magit: zibann> nil #<marker at 1 in *magit: zibann> nil nil nil nil nil nil #6 nil] [cl-struct-magit-secti\
on stash "stash#{12}" #<marker (moves after insertion) at 749 in *magit: zibann> nil #<marker at 1 in *magit: zibann> nil nil nil nil nil nil #6 nil] [cl-struct-magit-section stash "stash#{13}" #<marker (moves after insertion) at 749 in *magit: zibann> nil #<marker at 1 \
in *magit: zibann> nil nil nil nil nil nil #6 nil] [cl-struct-magit-section stash "stash#{14}" #<marker (moves after insertion) at 749 in *magit: zibann> nil #<marker at 1 in *magit: zibann> nil nil nil nil nil nil #6 nil])] nil] keymap (keymap (65 . magit-stash-pop) (97\
. magit-stash-apply) (remap keymap (magit-delete-thing . magit-stash-drop) (magit-visit-thing . magit-stash-show))))) "magit:" "calendar util" "reduc" "calendar contain" "toolbar" "gud" "actions" "toolbar" "month" "day" "dates" "web" "view" "py bun" "py" "dates" "viewse\
t" "gud" "produ" "gud" "actions" "day." "js" "/home/eugenekim/Documents/zibann/momsite/apps/reservation/" "reservation calendar" "gud" "bundle" "day" "dates" "gud" "calendar" "day." "calendar " "month" "gud" "py" "month" "gud" "day" "/home/eugenekim/Documents/zibann/moms\
ite/apps/reservation/static/reservation/calendar/actions/" "actions" "base" #("product" 0 7 (fontified t font-lock-face font-lock-string-face)) "/home/eugenekim/Documents/zibann/momsite/apps/saleor/product/rest/viewsets/product/bundle_product/bundle_product.py" "regul" "\
gud" #("product" 0 7 (fontified t font-lock-face font-lock-string-face)) ".js view" "produc" "product py" "/home/eugenekim/Documents/zibann/momsite/apps/reservation/static/reservation/calendar/reducers/" "reducer" "day" "gud" "actions" "mon" "produc py" "js" "month" "dat\
es" "month" "actions" "month" "day" "/home/eugenekim/Documents/zibann/momsite/apps/reservation/static/reservation/calendar/reducers/ind" "/home/eugenekim/Documents/zibann/momsite/apps/reservation/static/reservation/calendar/reducers/dates.react.js" "/home/eugenekim/Docum\
ents/zibann/momsite/apps/reservation/static/reservation/calendar/reducers/" "days" "calendar" "day." "actions"))
Related
func uploadImage(imageData : Data, path : String,completion: #escaping (String) -> ()) {
let storage = Storage.storage().reference()
let uid = Auth.auth().currentUser!.uid
storage.child(path).child(uid).putData(imageData, metadata: nil) { (_, err) in
if err != nil {
completion = ("")
return
}
//Downloading url and sending back
storage.child(path).child(uid).downloadURL { (url, err) in
if err != nil {
completion = ""
return
}
completion = ("\(url)")
}
}
}
You need to write completion like this completion(<#value here#>) not to assign it
func uploadImage(imageData : Data, path : String,completion: #escaping (String) -> ()) {
let storage = Storage.storage().reference()
let uid = Auth.auth().currentUser!.uid
storage.child(path).child(uid).putData(imageData, metadata: nil) { (_, err) in
if err != nil {
completion("")
return
}
//Downloading url and sending back
storage.child(path).child(uid).downloadURL { (url, err) in
if err != nil {
completion("")
return
}
completion("\(url)")
}
}
}
You don't need to assign a value to completion parameter, you need to invoke it like following -
storage.child(path).child(uid).putData(imageData, metadata: nil) { (_, err) in
if err != nil {
completion("")
return
}
//Downloading url and sending back
storage.child(path).child(uid).downloadURL { (url, err) in
if err != nil {
completion("")
return
}
completion("\(url)")
}
}
This question already has answers here:
What does "Fatal error: Unexpectedly found nil while unwrapping an Optional value" mean?
(16 answers)
Closed 4 years ago.
#IBAction func login(_ sender: Any) {
guard emailField.text != "", passField.text != "" else {return}
Auth.auth().signIn(withEmail:emailField.text!,password:passField.text!, completion: { (user, error) in
if let error = error {
print(error.localizedDescription)
I get this error:
Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value.
Try:
guard let email = self.emailField.text, let password = self.passField.text else { return }
if email != "" && pass != "" {
Auth.auth().signIn(withEmail: email, password: password) { (user, err) in
if err != nil { print(err.localizedDescription); return }
// do something
}
}
this is my code I want the user name not to have spaces and lowercase
example (wizkhalifa)
func textField(_ textFieldToChange: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
if textFieldToChange == username {
let characterSetNotAllowed = CharacterSet.whitespaces
if let _ = string.rangeOfCharacter(from:NSCharacterSet.uppercaseLetters) {
return false
}
if let _ = string.rangeOfCharacter(from: characterSetNotAllowed, options: .caseInsensitive) {
return false
} else {
return true
}
}
if UserNameField.text != nil, emailField.text != nil, passwordField.text != nil, rePassword.text != nil && passwordField.text == rePassword.text {
Auth.auth().createUser(withEmail: emailField.text!, password: passwordField.text!, completion: { (user, error) in
if error != nil {
AlertController.showAlert(self, titel: "Error", message: " Fill all fields \nUser exists ")
return
}
You need to check 2 things and you can put that check in the method called when trying to create a user, and/or when the user is typing.
First check, spaces :
if let text = UserNameField.text {
if text.components(separatedBy: " ").count > 1 && text.lowercased() != textField.text {// add your other tests on this line
// the text is in lowercase without space character and your tests pass
Auth.auth().createUser(withEmail: emailField.text!, password: passwordField.text!, completion: { (user, error) in
// check if there is an error
})
} else {
AlertController.showAlert(self, titel: "Error", message: " Fill all fields \nUser exists ")
}
Here is the version for OP with his code :
if UserNameField.text != nil, emailField.text != nil, passwordField.text != nil, rePassword.text != nil && passwordField.text == rePassword.text && UserNameField.text.components(separatedBy: " ").count <= 1 && UserNameField.text.lowercased() == UserNameField.text {
Auth.auth().createUser(withEmail: emailField.text!, password: passwordField.text!, completion: { (user, error) in
if error != nil {
AlertController.showAlert(self, title: "Error", message: " Fill all fields \nUser exists ")
return
} else {
// all good
}
})
} else {
AlertController.showAlert(self, title: "Error", message: " Fill all fields \nUser exists ")
}
I am new in Swift. My question is I am not sure how to unwrapping the optional value. When I print the object.objectForKey("profile_picture"), I can see Optional(<PFFile: 0x7fb3fd8344d0>).
let userQuery = PFUser.query()
//first_name is unique in Parse. So, I expect there is only 1 object I can find.
userQuery?.whereKey("first_name", equalTo: currentUser)
userQuery?.findObjectsInBackgroundWithBlock({ (objects: [PFObject]?, error: NSError?) -> Void in
if error != nil {
}
for object in objects! {
if object.objectForKey("profile_picture") != nil {
print(object.objectForKey("profile_picture"))
self.userProfilePicture.image = UIImage(data: object.objectForKey("profile_pricture")! as! NSData)
}
}
})
You'd use if let to perform "optional binding", only performing the block if the result in question is not nil (and binding the variable profilePicture to the unwrapped value in the process).
It would be something like:
userQuery?.findObjectsInBackgroundWithBlock { objects, error in
guard error == nil && objects != nil else {
print(error)
return
}
for object in objects! {
if let profilePicture = object.objectForKey("profile_picture") as? PFFile {
print(profilePicture)
do {
let data = try profilePicture.getData()
self.userProfilePicture.image = UIImage(data: data)
} catch let imageDataError {
print(imageDataError)
}
}
}
}
Or, if you want to get data asynchronously, perhaps:
userQuery?.findObjectsInBackgroundWithBlock { objects, error in
guard error == nil && objects != nil else {
print(error)
return
}
for object in objects! {
if let profilePicture = object.objectForKey("profile_picture") as? PFFile {
profilePicture.getDataInBackgroundWithBlock { data, error in
guard data != nil && error == nil else {
print(error)
return
}
self.userProfilePicture.image = UIImage(data: data!)
}
}
}
}
It would be something along those lines, using if let to unwrap that optional. And you then have to get the NSData associated with that the PFFile object (from the getData method or getDataInBackgroundWithBlock, presumably).
See Optional Binding discussion in The Swift Programming Language.
I'm getting my feet wet with lisp and came across an (I think) unusual problem. I'd like to create very long lists; ie, something like (setf *mat* (make-list 1000000)), but without having Nil printed out a million times on the screen.
The best I came up with is...
(let () (setf *mat* (make-list 1000000)) (length *mat*))
(or some other short but useless function at the end of the closure)
...but I suspect there is a better solution to avoid these sesquipedalian printouts. Any input is appreciated. Btw, I'm using Clozure v1.10 under Windows 7.
Usually one would call (values) at the end.
Common Lisp has a way to deal with long output at the printer level:
Welcome to Clozure Common Lisp Version 1.9-dev-r15612M-trunk (DarwinX8664)!
? *print-length*
NIL
? (setf *print-length* 100)
100
? (make-list 1000000)
(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL
NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL
NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL
NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL
NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL
NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL
NIL NIL NIL NIL ...)
*print-length* here is the variable which controls it.
An alternative to setting *print-length* is to use defparameter instead of setf on the repl. defparameter returns the symbol instead of the value:
(defparameter *mat* (make-list 10000))
-> *mat*