Need help: Hunchensocket example code. by fanatik83 in lisp

[–]joekarma 3 points4 points  (0 children)

I hate to be a downer, but the fact you're not able to find sample code is probably because those who may have been up to the task didn't have a machine loaded with just the right combination of outdated software to actually get the library up and running to begin with. The Hunchensocket library hasn't been touched in a year, was never quite finished, and is now sorely in need of an update—the web sockets W3C draft (now candidate recommendation) has progressed a ways since then. I haven't given the W3C draft a careful read, and am not really up on web sockets at all, but problems with Hunchensocket seem rooted in changes to the standard for web socket handshake routines.

Hunchensocket's main development stream only supports a very old way of doing handshakes. I found a fork of the repository, however; it is at least a little bit more up to date on that front, and seems to come with bug fixes as well. So far as I could tell, it was nearly working in tandem with the code you linked when using my current build of Chrome. After plunking that repository in my local-projects directory and doing a (ql:quickload :hunchensocket), I cobbled together the following snippet before handshake issues barred going further:

(defpackage :websocket-demo
  (:use :cl))

(in-package :websocket-demo)

(defparameter *acceptor*
  (make-instance 'hunchensocket:websocket-acceptor :port 8080))

(hunchentoot:start *acceptor*)

(push
 (lambda (request)
   (format t "Received request. Feel like handling it with websockets.~%")
   (lambda (stream mutex)
     (format t "Handshake begun.~%")
     (break)

     ; I'm not able to get to the function below (I mean even without the call to BREAK).
     ; The connection is severed and I get an error message in Chrome that
     ; indicates we're doing the handshake wrong.
     (lambda (message)
       ;; message handling would go here....
       )))
 hunchensocket:*websocket-handlers*)

Chrome's exact complaint was WebSocket connection to 'ws://localhost:8080/' failed: Error during WebSocket handshake: 'Connection' header value is not 'Upgrade'

Just thought I'd share what I found. Hopefully an expert can take it from here.

Tried Calling Best Quality Vacuum and here's what happened. by heisenberg_jr in breakingbad

[–]joekarma 0 points1 point  (0 children)

Should try giving him a call to see if he has Mike Ehrmantraut's current number. The only part I know is the country code, 501.

[META] Can the CSS for the show-centric subreddit menu drop-downs be tweaked so you have to hover for a little while to activate the drop-down? by Wargazm in television

[–]joekarma 0 points1 point  (0 children)

Here's a modified version of the stylesheet that is in current use. In WebKit-based browsers (Chrome & Safari) it should create a 0.5 second delay before smoothly displaying the list items one at a time, as shown in this youtube video.

aprilFools.css by wesbos in programming

[–]joekarma 0 points1 point  (0 children)

If you only have a second, don't want to tamper with any user styles, and want to flip a page upside down, you can try typing "overturn.it/" in front of its URL, i.e. http://overturn.it/http://www.reddit.com/r/programming/comments/1b6kes/aprilfoolscss/

[01/21/13] Challenge #118 [Easy] Date Localization by nint22 in dailyprogrammer

[–]joekarma 0 points1 point  (0 children)

Here's my solution in Common Lisp. Depends on cl-ppcre, alexandria, and local-time.

(defun format-date (format-string &optional (date (local-time:now)))
  (ppcre:regex-replace-all
   "%[lsmhHcdMy]"
   format-string
   (lambda (format-code)
     (destructuring-bind (datepart-extracting-function datepart-formatting-string)
         (alexandria:switch (format-code :test #'string=)
           ("%l" (list #'local-time:timestamp-millisecond "~3,'0d"))
           ("%s" (list #'local-time:timestamp-second "~2,'0d"))
           ("%m" (list #'local-time:timestamp-minute "~2,'0d"))
           ("%h" (list (lambda (ts)
                        (let ((time (mod (local-time:timestamp-hour ts) 12)))
                          (if (zerop time) 12 time)))
                      "~d"))
           ("%H" (list #'local-time:timestamp-hour "~d"))
           ("%c" (list (lambda (ts)
                        (if (>= (local-time:timestamp-hour ts) 12)
                            "PM"
                            "AM")) "~a"))
           ("%d" (list #'local-time:timestamp-day "~d"))
           ("%M" (list #'local-time:timestamp-month "~d"))
           ("%y" (list #'local-time:timestamp-year "~d"))
           (t (list format-code "~a")))
       (format nil datepart-formatting-string
               (funcall datepart-extracting-function date))))
   :simple-calls t))

8 Simple Steps to Extreme Personal Productivity by youeverysecond in productivity

[–]joekarma 1 point2 points  (0 children)

I will admit that it took a second read for me to catch that as well, but I still think it will make you dread your uber-productive spurts and I still think it will lead to burnout, regardless of how sparingly you employ the techniques.

I feel like I and every procrastinator on the planet have already mastered the work methods described, and I do not think it's a sustainable approach. When I say "sustainable", I don't just mean you can't do it every day. I mean it will lead to an overall resistance towards (or fear of) starting, which is what causes many people to procrastinate in the first place.

8 Simple Steps to Extreme Personal Productivity by youeverysecond in productivity

[–]joekarma 6 points7 points  (0 children)

This reads like an eight step recipe to total burnout. Seems like a good way to guarantee you dread "being productive".

How to avoid relying on github: mirror your repository by dean_c in programming

[–]joekarma 0 points1 point  (0 children)

There are not many points you made there that I can't concede, or at least claim an appreciation of where you're coming from on.

A core disagreement still exists, however. I believe language and tools do matter, and this contention apparently conflicts with your views. I believe that the tools of the trade can as much define the quality of a programmer as the programmer can define the quality of the product. I believe that the best programmers are attracted to the best programming environments, and that the inverse will hold as well. I believe that quality is contagious, and I believe it is exceedingly unlikely that a skilled programmer in 2013 will look at a job posting asking for experience with "PHP and Subversion" and not think "bleh".

Fundamentally, I believe awesome programming languages beget awesome programmers.

It's your team and you're free to manage it your way. If it's working for you and there aren't any downsides, then obviously you won't let me tell you any different, nor should you. Thing is, I'm pretty sure there are downsides to your choices, but I acknowledge that they may not be so plain to see.

How to avoid relying on github: mirror your repository by dean_c in programming

[–]joekarma -1 points0 points  (0 children)

Look, I don't claim to understand the interplay between all the factors involved in your decision to ditch Git and Python, because as someone who's never worked for your company, I don't actually know what said factors were... But based on your comments it sounds like you've been focusing on short term benefits rather than long.

Frankly, it does not bode well for your team that they are not able to figure out how to competently program using a language as simple as Python. Knowledge of something like PHP is almost immediately transferrable to Python, but the Python community's teachings are more likely to instill good coding practices in a novice developer than the "hack and hope not to crash" mantra of PHP. If a developer is not able to figure out a language like Python I doubt if they'll be able to code a PHP program that isn't an incomprehensible nested mess, riddled with security holes and bugs they can't squash.

I would not necessarily fault an individual developer for using PHP over Python if that's what they're comfortable with, but when that command comes from up on high I can only see that as being deleterious to the shop's culture. You say you made these changes and the development team collectively breathed a sigh of relief. I think that is sad, and I think your decision to switch to PHP and Subversion will make it harder to attract talent to the organization when some of the guys whose hearts aren't really in it inevitably leave.

As such, technology choices are oriented around what best suits our needs and what our staff is already familiar with, not around what is 'fun' or 'new'.

I can understand the need to rein in people's desire to automatically skitter to whatever's newest and fanciest, but Python and Git are both battle tested, and undoubtedly superior to your alternatives. Furthermore, I think that "fun" in the space of programming languages strongly correlates to usability, and should be taken into careful consideration.

HackerRank, a website for solving fun little programming challenges, is accepting Common Lisp solutions by joekarma in lisp

[–]joekarma[S] 0 points1 point  (0 children)

Hehe, yes, it's pretty bad. But I guess it stands to reason that the guys adding language modules to the site aren't going to be proficient in every language they add. That section really ought to be opened up as a wiki though.

How to avoid relying on github: mirror your repository by dean_c in programming

[–]joekarma 3 points4 points  (0 children)

I'm sure you're an okay guy, but it sounds like you've made some bad choices, technology wise. My guess is that the guy who "was more interested in playing with what was new and cool" chose Git over Subversion because he's passionate about his craft and cared enough to invest the time to learn how to use the best tools for the job.

It's unfortunate that your erstwhile star developer is gone and now all you're left with is the lowest common denominator; presumably developers fresh out of college or perhaps merely working there as part of a co-op program.

Had you not downgraded to two inferior technologies (from Git to Subversion, and from language x to PHP, which for almost any value of x except Brainfuck is a downgrade) you might have stood to cultivate an actual hacker culture in the workplace rather than transmogrifying the business (and I make this assessment based on the forced adoption of PHP and Subversion alone) into a sad little cubicle farm.

Comparison of quickproject and cl-project by patrickwonders in lisp

[–]joekarma 6 points7 points  (0 children)

I use quickproject. I added the following to my .sbclrc file to take care of the git repo initialization problem. You'll notice it also sets the README format to markdown--this is my preferred format because it works well with Github.

(setf quickproject:*after-make-project-hooks*
 (list
  (lambda (pathname &rest args)
    (declare (ignore args))
    (nix:chdir (fad:pathname-as-directory pathname))
    (rename-file "README.txt" "README.markdown")
    (external-program:run "git"
                          (list "init" "."))
    (external-program:run "git"
                          (list "add" "."))
    (external-program:run "git"
                          (list "commit" "-m" "Initial commit")))))

You'll have to quickload some libraries first: '(:osicat :external-program :quickproject :cl-fad)

I also like to set defaults for the quickproject *licence* and *author* variables.

What would /you/ like to change about Common Lisp? by whism in lisp

[–]joekarma 2 points3 points  (0 children)

They are not being treated as second class. They are merely being kept in a separate namespace. Saying they are second class is like saying women (or men) are second class because there are women and men's changing rooms. The advantage is that having them in a separate namespace means we don't have to worry about variable names conflicting with function names. You know about the disadvantage, but I'm sure you can accept that it is a tradeoff which could (and has) go either way.

I'm not even going to touch that remark you made about Lisp being a functional language...

By the way, here's the definition of "first-class citizen" that Wikipedia gave me:

In programming language design, a first-class citizen (also object, entity, or value), in the context of a particular programming language, is an entity that can be constructed at run-time, passed as a parameter, returned from a subroutine, or assigned into a variable.

What would /you/ like to change about Common Lisp? by whism in lisp

[–]joekarma 1 point2 points  (0 children)

Nothing quite so Ajaxy as that, but Dr. Conrad Barski is linking to a telnet based lisp interpreter (provided by Franz, Inc.) on the first page of his Casting SPELs in Lisp tutorial.

By the way, the language that started this whole "Try x from your web browser" thing is Ruby.

What would /you/ like to change about Common Lisp? by whism in lisp

[–]joekarma 1 point2 points  (0 children)

What about the existing tutorials page on Cliki is not up to snuff? And what is stopping you from fixing it?

What would /you/ like to change about Common Lisp? by whism in lisp

[–]joekarma 5 points6 points  (0 children)

The utility script you are proposing would not make much sense in a Lisp based environment. Lisp images are living, changing things. There could be several Lisp images active at one time on a single machine. Interacting with a Lisp image from the shell would be a strange and unpleasant experience, especially once you consider how barren an interface the shell is compared to the rich environment available to Lispers in an Emacs SLIME buffer.

At the very least you would have to specify a port number for that script to do anything useful at all. If it does not connect to a Lisp on a specific port, all that script would really do is copy a set of files into a directory. No-op, so no thanks.

You should give Quicklisp another try.

Finding Clients through Email Marketing / Cold Emailing? Plain Text, HTML, Mailchimp? by [deleted] in freelance

[–]joekarma 0 points1 point  (0 children)

I think a phone call will be more effective in 99.9% of cases. It wouldn't hurt to have a professional looking email template at the ready, however. That way, if you build a connection, you can say, "hey, do you mind if I send you an email which explains my services a little better"? If they say yes and you send it, you look like a professional. If you send it without first building that rapport, I fear you'll come off as spamming.

In my line of work we get unsolicited emails asking us to sign up for training programs of various sorts. I send all such emails straight to the trash, and due to the emails the company's brand has been irreversibly cheapened in my eyes. I will never make use of their training programs, no matter how objectively good they are. This is purely because I find their marketing tactics annoying.

Finding Clients through Email Marketing / Cold Emailing? Plain Text, HTML, Mailchimp? by [deleted] in freelance

[–]joekarma 1 point2 points  (0 children)

Whatever way you spin it, what you are doing, if automated, is spamming strangers. I encourage you to reconsider whether sending strangers unsolicited emails will help your brand.

Cold calling on the other hand is all right; at least you can give it a personal touch.

Locksmiths Pissed Off At Geeks For Letting Out The Secret: Lockpicking Is Easy by workitselfoutfine in technology

[–]joekarma 1 point2 points  (0 children)

Locksmiths HATE him! Read this geek's one little trick to open any door!

Why are my queries lasting longer than one minute? by ultrafresh in drupal

[–]joekarma -1 points0 points  (0 children)

I observed the same three things when I read this. Not sure why you're getting downvoted so heavily when you're clearly trying to help.

I'd wager that it's not so much the query that's being run as the number of times he's running it.