Skip to content

Instantly share code, notes, and snippets.

View kzar's full-sized avatar
🐈
Bashing the rocks together...

Dave Vandyke kzar

🐈
Bashing the rocks together...
View GitHub Profile
@kzar
kzar / Stacktrace
Created November 9, 2011 15:56
clutch 0.3.0 Snapshot problem
clojure.lang.PersistentArrayMap cannot be cast to java.lang.String
[Thrown class java.lang.ClassCastException]
Restarts:
0: [QUIT] Quit to the SLIME top level
Backtrace:
0: com.ashafa.clutch.utils$url.invoke(utils.clj:105)
1: com.ashafa.clutch$with_db_STAR_$fn__2316.doInvoke(clutch.clj:57)
2: clojure.lang.RestFn.invoke(RestFn.java:436)
@kzar
kzar / LogWriter.py
Created November 29, 2011 16:36
Quick (untested) example of logging standard out and error to a file
import sys
def log(s, file_name):
with open(file_name, "a") as log_file:
log_file.write(s)
def LogWriter:
def write(self, s):
log(s, "path/to/logfile")
sys.stdout = sys.stderr = LogWriter()
@kzar
kzar / gist:1409810
Created November 30, 2011 17:01
Exception thrown with Clutch 0.3.0-SNAPSHOT when uploading attachment with space in name
java.io.IOException: Error writing to server
at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:578)
at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:590)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1193)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
at com.ashafa.clutch.http_client$get_response.invoke(http_client.clj:58)
at com.ashafa.clutch.http_client$connect.invoke(http_client.clj:92)
at com.ashafa.clutch.http_client$couchdb_request.doInvoke(http_client.clj:116)
at clojure.lang.RestFn.invoke(RestFn.java:521)
at com.ashafa.clutch$update_attachment.doInvoke(clutch.clj:404)
@kzar
kzar / ssh-tunnel.clj
Created December 7, 2011 16:57
Open and keep open a SSH tunnel using Clojure
(ns ssh-tunnel.core
(require [clj-ssh.ssh :as ssh]))
(defn ssh-tunnel
"Run a ssh tunnel in a deamon thread."
[session local-port remote-port]
(ssh/with-local-port-forward [session local-port remote-port]
(.setDaemonThread session true)
(ssh/with-connection session
(.setServerAliveInterval session 1000)
@kzar
kzar / Ankit Srivastava from Experttag
Created December 8, 2011 13:01
SEO contact form spammers
Hi,
Greeting or the day,
It’s a Human tendency that we start with a website and leave it like that, If you are not happy with the amount of business that you are getting from your website, we assure you that it won’t be happening any more as soon you start with our SEO Service.
There are some special Keywords that are placed in the website which help the website to increase the ranking and increase the traffic on it.
Check the desired keyword related to your business on the Google, You won't find your website appearing on the first page of the Search Engine and this is the Point where you lose your business.
@kzar
kzar / Errors
Created December 11, 2011 16:35
Slime errors when a lot of data is returned
error in process filter: sldb-frame.string: Wrong number of arguments: nil, 0
error in process filter: Wrong number of arguments: nil, 0
Debugger entered--Lisp error: (end-of-file)
byte-code("\302\300\"\210\303 \304\"\210\300\305\"\207" [error process debug slime-net-close t "net-read error: %S"] 3)
slime-net-read-or-lose(#<process SLIME Lisp>)
slime-process-available-input(#<process SLIME Lisp>)
slime-net-filter(#<process SLIME Lisp> "ecto, :rel alternate}, :content nil} {:tag :summary, :attrs {:type html}, :content [When making the last lisp program I found it hard to visualise the working days between two dates. I ended up drawing these little sketches on a bit of paper to figure out if my program was doing the ...]} {:tag :category, :attrs {:term lisp}, :content nil} {:tag :category, :attrs {:term project}, :content nil} {:tag :published, :attrs nil, :content [2008-08-25T01:00:00+01:00]}]} {:tag :entry, :attrs nil, :content [{:tag :id, :attrs nil, :content [http://kzar.co.uk/blog/view/generatin
@kzar
kzar / test.rb
Created January 5, 2012 12:39
Ruby &&= operator
ruby-1.9.2-p0 :001 > a = nil
=> nil
ruby-1.9.2-p0 :002 > a = (a and nil)
=> nil
ruby-1.9.2-p0 :003 > a = nil
=> nil
ruby-1.9.2-p0 :004 > a = (a and 1)
=> nil
ruby-1.9.2-p0 :005 > a = 1
=> 1
@kzar
kzar / core.clj
Created January 9, 2012 21:35
Mr Site password protection vulnerability
; Mr Site Password protection
; http://www.mrsite.com/videos/Tips_and_tricks_%E2%80%93_putting_a_password_on_your_web_pages/19525203
;
; The problem
; -----------
; For some reason Mr Site "secures" pages with Javascript client side password protection,
; instead of using HTTP basic authentication or with server side code. Anyone can click
; "view source" and view the secrets. Worse, the password hash is available so anyone could
; figure out the password used.
;
@kzar
kzar / dependencies
Created January 16, 2012 11:09
clj-ssh 0.3.1-SNAPSHOT slingshot not found
:dependencies [[org.clojure/clojure "1.3.0"]
[noir "1.2.2"]
[com.ashafa/clutch "0.3.0"]
[clj-yaml "0.3.1"]
[xml-picker-seq "0.0.2"]
[xom/xom "1.2.5"]
[org.clojure/data.json "0.1.1"]
[clj-time "0.3.1"]
[clj-http "0.2.3"]
[net.cgrand/moustache "1.0.0"]
@kzar
kzar / gist:1886120
Created February 22, 2012 17:10
Javascript scope issue
function test() {
return typeof(the_variable) !== 'undefined' && the_variable;
}
(function () {
var the_variable = "doesn't work";
console.log(test());
}());
var the_variable = "does work";